package app.datavalue;

public enum MsgDeliveryFinalStatus 
{
	
    ACCEPTED(1)
,
    DELETED(2)
,
    DELIVERED(3)
,
    EXPIRED(4)
,
    REJECTED(5)
,
    UNDELIVERABLE(6)
,
    UNKNOWN(0)	;
    
    
	private final int code;
	
    MsgDeliveryFinalStatus( int code )
	{
		this.code = code;
	}
	
	public int toInt() { return code; }

    public static MsgDeliveryFinalStatus fromInt(int code) 
    {

        
        if ( testCode(ACCEPTED, code) )
        	return ACCEPTED;
        else	
            if ( testCode(DELETED, code) )
            	return DELETED;
            else
                if ( testCode(DELIVERED, code) )
                	return DELIVERED;
                else
                    if ( testCode(REJECTED, code) )
                    	return REJECTED;
                    else
                        if ( testCode(UNDELIVERABLE, code) )
                        	return UNDELIVERABLE;
                        else
                            if ( testCode(UNKNOWN, code) )
                            	return UNKNOWN;

                            	
        
         throw new RuntimeException("Unknown MsgDeliveryFinalStatus code");
    }    
    
    public static boolean testCode( MsgDeliveryFinalStatus status , int code )
    {
    	return status.code == code;
    }   
    
}
